package Entidad;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.*;


@Entity
public class Movie implements Serializable {
    
    @Id 
    @Column(name="NAME",length=250,nullable=false)
    private String Name;
    @Column(name="AÑO",nullable=true)
    private Integer Year = null;
    @Column(name="COVER",length=250,nullable=true)
    private String Cover = "Desconocido";
    @Column(name="PLOTKEYWORDS",length=250,nullable=true)
    private String PlotKeywords = "Desconocido";
    @Column(name="GENRE",length=250,nullable=true)
    private String genre = "Desconocido";
    @Column(name="RATING",nullable=true)
    private Float rating = null;
    @Column(name="DURATION",nullable=true)
    private Float duration = null;
    @Column(name="AVAILABLEFORRENTAL",nullable=true)
    private Boolean availableForRental = true;
    @Column(name="AVAILABLEFORPURCHASE",nullable=true)
    private Boolean availableForPurchase = true;
    
    
        
    @ManyToOne(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST,CascadeType.REMOVE},optional=false)
    @JoinColumn(name = "Director")
    private Director director;
   
    @ManyToMany(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    @JoinTable(name="Actors_Movie")
    private List<Actor> actores = new ArrayList<>();
     
    @OneToOne(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST,CascadeType.REMOVE},optional=false)
    @JoinColumn(name = "Soundtrack")
    private Soundtrack soundtrack;

    public Movie(){
        
    }
    
    public Movie(String Name, Integer Year, String Cover, String PlotKeywords, String genre, Float rating, Float duration, Boolean availableForRental, Director director, List<Actor> actores, Soundtrack soundtrack, Boolean availableForPurchase) {
        this.Name = Name;
        this.Year = Year;
        this.Cover = Cover;
        this.PlotKeywords = PlotKeywords;
        this.genre = genre;
        this.rating = rating;
        this.duration = duration;
        this.availableForRental = availableForRental;
        this.director = director;
        this.actores = actores;
        this.soundtrack = soundtrack;
        this.availableForPurchase = availableForPurchase;
    }
    
    public List<Actor> getActores() {
        return actores;
    }

    public void setActores(List<Actor> actores) {
        this.actores = actores;
    }

    public Director getDirector() {
        return director;
    }

    public void setDirector(Director director) {
        this.director = director;
    }

    public Soundtrack getSoundtrack() {
        return soundtrack;
    }

    public void setSoundtrack(Soundtrack soundtrack) {
        this.soundtrack = soundtrack;
    }
    
    public String getCover() {
        return Cover;
    }

    public void setCover(String Cover) {
        this.Cover = Cover;
    }

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public String getPlotKeywords() {
        return PlotKeywords;
    }

    public void setPlotKeywords(String PlotKeywords) {
        this.PlotKeywords = PlotKeywords;
    }

    public Integer getYear() {
        return Year;
    }

    public void setYear(Integer Year) {
        this.Year = Year;
    }

    public Boolean getAvailableForPurchase() {
        return availableForPurchase;
    }

    public void setAvailableForPurchase(Boolean availableForPurchase) {
        this.availableForPurchase = availableForPurchase;
    }

    public Boolean getAvailableForRental() {
        return availableForRental;
    }

    public void setAvailableForRental(Boolean availableForRental) {
        this.availableForRental = availableForRental;
    }

    public Float getDuration() {
        return duration;
    }

    public void setDuration(Float duration) {
        this.duration = duration;
    }

    public String getGenre() {
        return genre;
    }

    public void setGenre(String genre) {
        this.genre = genre;
    }

    public Float getRating() {
        return rating;
    }

    public void setRating(Float raiting) {
        this.rating = raiting;
    }
 }


